#ifndef MAINDIALOG_H
#define MAINDIALOG_H

#include <QtGui>

#include "ui_maindialog.h"

class MainDialog : public QDialog {
    Q_OBJECT
public:
    MainDialog(QWidget *parent = 0);

private slots:
    void on_tbUp_clicked();
    void on_tbDown_clicked();
    void on_tbTop_clicked();
    void on_tbBottom_clicked();

    //void on_tbDel_clicked();
    void on_actionDelete_triggered();

    void on_pbOk_clicked();

    void on_pbAbout_clicked();

    void on_pbUpdate_clicked();

    void on_pbStart_clicked();
    void on_pbStop_clicked();


    void addKeyFromPopup(QAction *act);
    void addLayoutFromPopup(QAction *act);

    void changeKeyFromPopup(QAction *act);

    void on_twConfig_customContextMenuRequested ( const QPoint & pos );


    void showAfterUpdate();

private:
    void fillKeyCodes();
    void addKey(unsigned vk);
    QTreeWidgetItem* insertKey(unsigned vk);
    void addLayout(unsigned klid, int idx);
    QTreeWidgetItem* insertLayout(QTreeWidgetItem *root, unsigned klid, int idx = -1);

    QTreeWidgetItem* currentKey();
    QTreeWidgetItem* findKeyItem(unsigned int vk);

    bool getConfiguration();
    bool readLocalSettings();
    bool writeLocalSettings();

    void restartResident();

    QMap<unsigned, QString> keyCodes;

    Ui::MainDialog ui;
    QMenu *popupMenu;
    QMenu *keysMenu, *keysChangeMenu, *layoutsMenu;
};

#endif // MAINDIALOG_H
